package cn.fengzhilun.javase.day10.ex;

import java.util.Arrays;

import org.junit.Test;

import cn.fengzhilun.javase.day06.Employee;

public class Demo {
	@Test
	public void test() {
		String s="abc";
		String ss="abc";
		
		String s1=new String("abc");
	}
	@Test
	public void test2() {
		String s1=new String("abc");
		
		System.out.println();
		
	}
	@Test
	public void test3() {
		System.out.println("abc中".length());
		
		String s="abc中";
		
		System.out.println(s.charAt(0));
		System.out.println(s.charAt(s.length()-1));
		
		char[] array =s.toCharArray();
		System.out.println(Arrays.toString(array));
		
		Employee e=new Employee();
		e.setName("张三丰");
		e.setAge(18);
		
		System.out.println("名字："+e.getName()+" 年纪:"+e.getAge());
		
		String message= String.format("名字：%s 年纪：%d 成绩: %.2f", e.getName(),e.getAge(),99.5);
		System.out.println(message);
		System.out.printf("名字：%s 年纪：%d" , e.getName(),e.getAge());
	}
	
	@Test
	public void test4() {
		String s= "abcdefg";
		
//		for(int i=0;i<s.length();i++) {
//			
//			System.out.println(s.charAt(i));
//		}
		
//		for(int i:s) {
//			
//			System.out.println(s.charAt(i));
//		}
		
		String[] array= {"abc","bce","gh"};
		
		String s1="";
		for(String i:array) {
			s1+=i;
			System.out.println("s1"+s1);
		}
		System.out.println(s1);
		
		String s2="index the index following the code point that should be returned";
		System.out.println(s2.indexOf("point"));
		
		int lastIndexOf = s2.lastIndexOf(" ");
		System.out.println(lastIndexOf+1);
		
	}
	@Test
	public void test5() {
		String s="ab"+123+"cd"+"de";
		
		StringBuffer sb=new StringBuffer();
		sb.append("ab");
		sb.append(123);
		sb.append("ce");
		sb.append("de");
		System.out.println(sb);
		sb.deleteCharAt(2);
		//String output= sb.toString();
		System.out.println(sb);
	}
	@Test
	public void test6() {
		StringBuilder sb= new StringBuilder();
		sb.append("abc");
		sb.append("edg");
		
		String str=sb.toString();
		System.out.println(str);
		System.out.println();
	}
}
